// pages/regist/regist.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    nickname:"",
    password:"",
    phone:""
  },
  onNickNameChange(evt){
    this.setData({
      nickname:evt.detail
    })
  },
  onPassWordChange(evt){
    this.setData({
      password:evt.detail
    })
  },
  onPhoneChange(evt){
    this.setData({
      phone:evt.detail
    })
  },
  regist(){
    let {nickname, password, phone} = this.data
    if(nickname && password && phone){
      wx.request({
        url: 'http://localhost:3000/api/register',
        method:"POST",
        data:{
          nickname: nickname,
          password: password,
          phone:phone
        },
        success: res => {
          if(res.data.code === 200){
            wx.navigateTo({
              url: '/pages/login/login',
            })
          }
        }
      })
    }
   
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },


})